#pragma once

#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#include <string>
#include <map> 
#include <iostream>
#include <fstream>
#include <errno.h>
#include <vector>
#include <sstream>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#include "pugixml/pugixml.hpp"

struct Cnaps2Node 
{
    string message_seqno;
    string message_nodeor;
    string message_desc;
    string message_xmltag;
    string message_iso2022_prop;
    string message_iso2022_type;
    string message_cnaps2_prop;
    string message_cnaps2_type;
    string message_remark;
    string message_signed;
    string message_fieldName;
};

class Cnaps2Connvert
{
private:
    string m_pktCode;
    string m_pktFile;
    string m_pktType;
    string m_sysCode;
    std::stack<pugi::xml_node> m_nodeStack;
public:
    Cnaps2Connvert(const string& pktCode,const string& pktType);
    ~Cnaps2Connvert() = default;

    int start();
private:    
    int convert(std::ifstream& ifstream);
    int convert(std::ifstream& ifs,pugi::xml_node& root_node);
    pugi::xml_node gen_policy_node(pugi::xml_node& root_node);
};